
package database;

//import java.sql.PreparedStatement;
//import java.sql.ResultSet;
//import java.util.ArrayList;
import user.UserAccount;

import java.io.IOException;
import java.io.PrintWriter;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.util.ArrayList;

import java.sql.*;
import java.util.*;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import java.io.File;
import java.io.IOException;




public class Registration extends Database {
   
    public Registration() {}

   public void registrate(String lastName, String firstName, String emailAddr, String passWord)
   {
	   
	   UserAccount userAccount = new UserAccount(lastName, firstName, emailAddr, passWord); 
	   
	   try
	   {
		   PreparedStatement statement = connection.prepareStatement(
				   "INSERT INTO `ualbanybook`.`useraccount` (lastName, firstName, Email, password)"
	               + " VALUES (?,?,?,?);");
	       statement.setString(1, userAccount.getLastName());
	       statement.setString(2, userAccount.getFirstName());
	       statement.setString(3, userAccount.getEmailAddr());
	       statement.setString(4, userAccount.getPassWord());
	       statement.executeUpdate();
               
               
               
               
	   }
	   catch (Exception e) { e.printStackTrace(); }
           
           /*
           
          try{
           File userpage =  new File("D:/UAlbanyBook/web/"+userAccount.getFirstName()+".jsp");
           boolean success = userpage.createNewFile();
           if(success){
               System.out.print(userAccount.getFirstName()+".jsp cerated!");
               
           }
           else
           {
               System.out.print(userAccount.getFirstName()+".jsp not cerated!");
           }
           }
           catch (IOException x) {
                // Some other sort of failure, such as permissions.
              System.err.format("createFile error: %s%n", x);
            }
            * 
            */

   }
}

	